<template>
  <div class="back" @click="backFn">返回</div>

  <router-view></router-view>
</template>

<script setup>
import { useRouter } from "vue-router";
import { Updater } from "@/utils/autoUpdate";
const router = useRouter();

const mode = import.meta.env.MODE;

if (mode === "production") {
  //实例化该类
  const up = new Updater({
    timer: 2000,
  });
  //未更新通知
  up.on("no-update", () => {
    console.log("未更新");
  });
  //更新通知
  up.on("update", () => {
    const flag = confirm("页面有更新内容,是否立即更新");
    if (flag) {
      window.location.reload();
    }
  });
}

const backFn = () => {
  router.back();
};
</script>

<style scoped lang="scss">
.back {
  position: fixed;
  right: 20px;
  top: 20px;
  z-index: 1;
  background-color: pink;
  border-radius: 12px;
  padding: 5px 12px;
  color: black;
  cursor: pointer;
}
</style>
